<template>
    <div class="storeInfo">
        <div class="head">    
            <el-form :model="form" class="headForm">
                <el-form-item label="">
                    <el-input v-model="form.nickname" placeholder="真实姓名/账号"></el-input>
                </el-form-item>
                <el-form-item label="">
                    <el-input v-model="form.username" placeholder="手机号"></el-input>
                </el-form-item>
                <el-button type="primary" icon="el-icon-search" @click="search">搜索</el-button>
                <el-button v-if="addShow" type="danger" @click="addHead">添加</el-button>
            </el-form>      
        </div>
         
        <!-- tab部分 -->
        <div class="tabContainer">
            <el-table :data="tableData" stripe style="width: 100%;text-align:center">
                <!-- 		手机号/账号	员工编号	身份	更新时间	操作 -->
                <el-table-column prop="room_name" label="头像">
                    <template slot-scope="scope"> 
                        <img :src="scope.row.thumb" alt="" style="width:50px;height:50px;">
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="真实姓名"></el-table-column>
                <el-table-column prop="mobile" label="手机号/账号"></el-table-column>                
                <el-table-column prop="staff_no" label="员工编号"> </el-table-column>
                <el-table-column prop="role_name" label="身份"></el-table-column>
                <el-table-column prop="update_time" label="更新时间" width="200"></el-table-column>
                <el-table-column  label="操作" prop="price_id" v-if="limitList.length>0">
                    <template  slot-scope="scope">            
                        <span v-for="(item,indexLimit) in limitList" :key="indexLimit" class="lightFont" @click="theClick(item.url,scope.row)">
                            <i>{{item.name}}</i><i v-if="indexLimit != limitList.length-1">&nbsp;|&nbsp;</i>
                        </span>
                    </template>

                </el-table-column>
                <el-table-column label="/"  v-else>/</el-table-column>

            </el-table>
                        
        </div>
        <!-- 分页部分 -->
        <el-pagination
            background
            layout="total, prev, pager, next, jumper"
            @current-change="changePage"
            :page-size="size"
            :current-page.sync="pageNum"
            :hide-on-single-page=true
            :total="total">{{total}}
        </el-pagination>
        


    </div>
</template>
<style lang="scss">
.el-table .cell{text-align: left}
</style>

<script>
import { abc } from "../../../../js/abc.js";
import {potUrl} from '../../../../js/config_url.js'; 
export default {
    data(){
        return {          
            tableData:[],
            total:50,
            size:20,
            pageNum:1,
            form:{
                size:20,
                page:'1'

            },
            limitList:[],
            addShow:false,
            
        }
    },
    mounted(){
        var that = this;
        that.getList()
        abc.limit(that,'staff')
        setTimeout(() => {
            that.limitList.map((item,i)=>{
                if(item.url == 'add'){
                    that.addShow = true;
                    that.limitList.splice(i,1)
                }
            })
        }, 500);
        
    },
    methods:{
        search(){
            const that = this;
            that.getList()
        },
        theClick(url,a){
            var that = this;
            console.log(url)
            if(url == 'edit'){
                
            }else{
                let twotipsurl = '',txt="";
                if(url == 'changePassword'){
                    twotipsurl = potUrl.staffreset;
                    txt="确认重置"+ a.name +"账号为默认密码meiktv_123吗"
                }else{
                    twotipsurl = potUrl.staffdel;
                    txt="确认删除"+ a.name +"员工得信息吗？"
                }
                abc.twoTips(that,twotipsurl,txt,{user_id:a.user_id},function() {
                    that.getList()
                })
            } 

        },           
        changePage(val){
            var that = this;
            console.log(that.form)
            that.pageNum = val;
            that.form.page = val;
            that.getList()
        },
        getList(){
            let that = this;
            abc.get(that,potUrl.stafflist,that.form,(res)=>{
                that.total = parseInt(res.data.length)
                that.tableData =  res.data
            });//列表
        },
        addHead(){

        }



    }
}

</script>